package com.hello.system.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

import com.hello.system.service.impl.AliyunSysFileServiceImpl;
import com.hello.system.service.impl.FastDfsSysFileServiceImpl;
import com.hello.system.service.ISysFileService;
import com.hello.system.service.impl.LocalSysFileServiceImpl;
import com.hello.system.service.impl.MinioSysFileServiceImpl;

/**
 * 文件上传配置
 * 
 * @author hello
 */
@Configuration
public class FileServiceConfig
{
    @Value("${file.type}")
    private String fileType;
    
    @Autowired
    private LocalSysFileServiceImpl localFileService;
    
    @Autowired
    private FastDfsSysFileServiceImpl fastDfsFileService;
    
    @Autowired
    private MinioSysFileServiceImpl minioFileService;
    
    @Autowired
    private AliyunSysFileServiceImpl aliyunFileService;

    @Bean
    @Primary
    public ISysFileService fileService()
    {
        if ("fastdfs".equals(fileType))
        {
            return fastDfsFileService;
        }
        else if ("minio".equals(fileType))
        {
            return minioFileService;
        }
        else if ("aliyun".equals(fileType))
        {
            return aliyunFileService;
        }
        
        // 默认本地存储
        return localFileService;
    }
}
